<?php

	class Answer extends Answer_model {
            
            protected $__relation = array(
			array('table' => 'question', 'foreign_key' => 'question_id')
		);

		function __construct() {
			parent::__construct();
		}
                
                function validateInput() {
                    if (!$this->content || trim($this->content) == '')
                        MessageHandler::add ("Missing answer content");
                    
                    if (!$this->question_id || $this->question_id == 0)
                        MessageHandler::add ("Missing question ID");
                    
                    return MessageHandler::countError() > 0 ? false : true;
                }
                
                function isDeleteAble($id) {
                    $member_answer = new MemberAnswerQuestion();
                    $member_answer->addWhere("answer_id = $id");
                    $member_answer->find();
                    
                    return $member_answer->countRows() > 0 ? false : true;
                }
	}
